<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="zh-cn" />
<meta name="robots" content="all" />
<meta name="author" content="Neaton" />
<meta name="Copyright" content="mr-fang.com" />
<meta name="Description" content="/>
<meta name="Keywords" content=""/>
<title>发表管理 - mr-fang.com</title>
{literal}
<style>
body,div,form,img,p,ul,ol,li,dl,dt,dd,embed,h1,h2,h3,h4,h5,h6,td,tr,span,fieldset,label,legend{margin:0; padding:0; border:0;}
body{color:#595959;font-family:Verdana,Tahoma,Helvetica,Arial,"宋体";font-size:12px;line-height:22px;backgroundx:url('/misc/images/bg.jpg');}
body, div, span, pre, textarea, input {font: 14px/1.231 Verdana,"宋体",sans-serif;}
a{text-decoration:none;color:#000000}
#main{width:100%;padding:0;text-align:center}
#nav{margin-top:65px}
#nav .current{color:#993300}
a:hover{color:#993300}
#content{margin-top:25px;width:917px;text-align:left}
#logo{margin-top:15px;}
#footer{margin-top:10px;color:#000000}
#hr{height:1px;line-height:1px;width:600px;background-color:gray;}
.messageBox{text-align:left;width:50%;}
.messageBox td{border-bottom:1px solid gray;}
.logininput{width:130px;background:transparent;border:0;border-bottom:1px solid black;height:20px;font-size:16px;font-weight:bold}
.loading{text-align:center;padding-top:123px; padding-bottom:263px;background-color:#FFFFFF}
#upload_box{background-color:#FFFFFF;position:absolute;width:500px;}
.flashFail{padding:100px 0 266px 135px;}
.flashFail .finner{display:inline-block;padding-left:18px;background:url('/misc/images/idx_map_flashfail.png') no-repeat 0 4px;}
.flashFail, .flashFail *{font-size:14px;}
.borderOn{border:1px solid #BFBFBF}
.time{margin: 20px auto;}
.time input{margin-left:15px}
.mainColor{color:#FF0099}
p input{padding:5px}
p.title input{margin-right:30px;width:400px;}
p .inputTitle{padding: 15px;}
.button {
    cursor: pointer;
    height: 40px;
    line-height: 32px;
    width: 195px;
}
.weight {font-weight:700}
.control {
    margin-top: 20px;
    margin-left: 200px;
    padding: 20px;
    position: absolute;
    text-align: center;
    width: 100px;
    z-index: 4;
}
a.u:link, a.u:visited, a.u:hover, a.u:active {
    text-decoration: underline;
}
a.gmC:link, a.gmC:visited {
    color: #666666;
}
.fontStyle {
    height: 400px;
    line-height: 1.5em;
    margin-top: 10px;
    padding: 10px;
    width: 580px;
}
.lesserColor {
    color: #666666;
}
.tab {
    margin-top:60px;
}
.tab a.borderOn:link, .tab a.borderOn:visited, .tab a.borderOn:hover, .tab a.borderOn:active{
    border-bottom-width: 0;
    display: block;
    line-height: 17px;
    margin: -59px 0 0 -21px;
    padding: 10px 50px;
    position: absolute;
    color: #FF0099;
}
.addButton {
    margin-top: 30px;
    width:200px;
    float:right;
}
.picBox {
    margin: 10px 40px 10px 0;
}
.clearfix {
}
.picBox div.r {
    padding-right: 276px;
    width: 464px;
}
.r {
    float: right;
}
.picBox .simple {
    padding-top: 10px;
}
.picBox .simple{
    height: auto !important;
    min-height: 150px;
    padding: 0;
}
.picBox .simple img {
    margin-top: 20px;
    padding: 5px;
    width: 100px;
    height
}
</style>
{/literal}
</head>
<body>

<div id="main">
    <div id="nav">
        <a href="/admin/intro">【 简 介 】</a>
        <a href="/admin/messageListUnpass">【 留言管理 】</a>
        <a href="/admin/articleList" class="current">【 文章管理 】</a>
        <a href="/admin/cateList">【 分类管理 】</a>
    </div>

    <center>
    <div id="content">
    <form action='/admin/articleAdd' method='post'>

    <div id="content_0" class="borderOn" style="padding:20px">
        <p class="time">发生时间:<input type="text" value="" size="20"  name="time_0" class="borderOn" id="time_0"></p>
        <p class="time">文章分类ID:
        <select name="cate_0" class="borderOn" id="cate_0">
        <option value="0">请选择</option>
        {foreach from=$cates item=c}
        <option value="{$c.data.cid}">{$c.data.c_title}</option>
        {if $c.subs}
        {foreach from=$c.subs item=s}
        <option value="{$s.cid}">--{$s.c_title}</option>{/foreach}
        {/if}
        {/foreach}
        </select></p>
        <p class="weight700">标题：</p>
        <p class="title">
            <input type="text" value="" size="45" id="title_0" name="title_0" class="borderOn inputTitle">
            <span id="textleft" class="mainColor font12">40</span>
        </p>
        <p class="thirdColor time">接下来,加入你想展示的文字/图片/音乐/视频...</p>

        <input type="button" onclick="addMenuShow(this, 0)" onfocus="this.blur()" value="&gt;&nbsp;插入模块" class="button weight mainColor">
        <input type="hidden" id="type_0" value="title" name="type_0">
    </div>
    <!--标题结束-->

    <!--文字模块开始-->
    <div id="content_1" class="tab borderOn" style="height:480px;padding:20px">
        <div style="border:width:70%;float:left;">
        <a href="#" class="borderOn weight">文 本</a>
        <p class="weight">标题：</p>
        <p class="title">
            <input type="text" onkeypress="if(event.keyCode==13||event.which==13)return false;" id="title_1" name="title_1" class="borderOn weight">
        </p>
        <textarea class="fontStyle borderOn lesserColor" id="text_1" name="text_1"></textarea>
        </div>
        <div class="addButton">
            <input type="hidden" id="type_1" value="text" name="type_1">
            <input type="button" onclick="addMenuShow(this, 1)" onfocus="this.blur()" value="&gt;&nbsp;插入模块" class="button weight mainColor">
            <br />
            <br />
            <input type="button" onclick="removeModule(1,'text')" onfocus="this.blur()" value="删除模块" class="button mainColor">
            <br>
        </div>
    </div>
        <!--文字模块结束-->

        <!--添加模块菜单开始-->
        <div style="display: none;" id="add_menu" class="control borderOn" style="background:#FFFFFF">
            <p class="weight">
                <a id="addTextModuleLink" href="javascript:void(0)" class="gmC u">文 本</a>
            </p>
            <p></p>
            <p class="weight">
                <a id="uploadLink" href="javascript:void(0)" class="gmC u">图 片</a>
            </p>
        </div>
        <!--添加模块菜单结束-->

        <!--上传图片flash开始-->
        <div id="upload_box" class="borderOn" style="display:none">
            <div id="upswf_div">
                <div class="loading"> <img src="/misc/images/loading.gif" />
                <p>加载中...</p>
                </div>
            </div>
            <div style="margins-top:-240px;text-align:center;padding:10px">
                <input type="button" id="cancelUpload" class="button weight" value="取消上传">
            </div> 
            <div class="flashFail" style="display:none">
                <span class="finner">为了正常使用上传功能, 您需要<br/>安装FLASH插件
                <a href="http://get.adobe.com/flashplayer/" target="_blank">立即安装</a></span>
            </div>
        </div>
        <!--上传图片flash结束-->

        <div style="float:right;margin:10px 0 10px 0;"><input type="submit" id="nextStep" value="下一步" class="button weight mainColor"></div>
        <input type="hidden" name="itemIdsList" id="itemIdsList">
        </form>
    </div>
    </center>

</div>
<div id="layer" style="display:none"></div>

<script type="text/javascript" src="/misc/scripts/jquery.min.js"></script>
<script type="text/javascript" src="/misc/scripts/swfobject.js"></script>
<script type="text/javascript">
{literal}
var insertAfterItemNum = 0;
var maxItemId = 1;
var itemIdsList = [0, 1];

function insertItemId(id, id1) {
    var i = $.inArray(id, itemIdsList);
    if (i == -1) {
        itemIdsList.push(id1);
    } else {
        itemIdsList.splice(i+1,0,id1);
    }
}

function removeItemId(id) {
    var i = $.inArray(id, itemIdsList);
    if (i != -1) {
        itemIdsList.splice(i, 1);
    }
}

function onuploaded(ids) {
    var a = ids.split(',');
    for (var i=0;i<a.length;i++) {
        addModule('pic', a[i]);
        maxItemId += 1;
        insertItemId(insertAfterItemNum, maxItemId);
    }
    hideLayer();
}

var flashvars = {
    maxcount: 10,
    maxsize: 4,
    uploadpath: '/admin/upload',
    callback: 'onuploaded'
};

var params = {
    menu: "false",
    scale: "noScale",
    allowFullscreen: "true",
    allowscriptaccess: "always",
    bgcolor: "#FFFFFF",
    wmode: 'transparent'
};

var attributes = {
   id:"MeishimultiUpload"
};

swfobject.embedSWF("/misc/scripts/multiUpload.swf", 
                   "upswf_div", "500", "450", "10.0.0", "/misc/scripts/expressInstall.swf", flashvars, params, attributes, 
                   function(e){
                        if(!e.success){
                            jQuery('#upswf_div').empty().append( jQuery('.flashFail').show() );
                        }
                   });

function addMenuShow(obj, num) {
    var p = jQuery(obj).position();
    insertAfterItemNum = num;
    jQuery('#add_menu').show().css({"left":p.left+"px","top":p.top+"px"});
}

function showLayer() {
    var w = jQuery(window).width();
    var h = document.documentElement.clientHeight + $(document).scrollTop();
    jQuery("#layer").toggle().css({"background":"none repeat scroll 0 0 #000000", "opacity":"0.2", "position":"absolute","left":0,"top":0,"width":w+"px","height":h+"px","z-index":1000});
}

function hideLayer() {
    jQuery('#layer').toggle();
    jQuery('#upload_box').toggle();
}

function removeModule(num, type) {
    jQuery('#content_'+num).remove();
    removeItemId(num);
}

function addModule(type, picid) {
    var url = '/admin/articleAddModule?maxItemId='+maxItemId+'&type='+type;
    if (picid > 0) {
        url += '&picid=' + picid;
    }
    $.getJSON(url, function(r){
            if (r.code > 0 || r.content == '') {
                alert('请求失败，请重试');
                return false;
            }
            jQuery('#add_menu').hide();
            jQuery('#content_' + insertAfterItemNum).after(r.content);
    });
}

jQuery(function(){
    jQuery('#uploadLink').click(function(){
        var l = (jQuery(window).width() - 500) / 2;
        var t = (document.documentElement.clientHeight - 450) / 2 + $(document).scrollTop();
        l = l <= 0 ? 50 : l;
        t = t <= 0 ? 50 : t;
        showLayer();
        jQuery('#add_menu').hide();
        jQuery('#upload_box').toggle().css({"left":l+"px", "top":t+"px", "z-index":1001});
    });

    jQuery('#cancelUpload').click(function(){hideLayer();});

    jQuery('#addTextModuleLink').click(function(){
        addModule('text', 0);
    });

    jQuery('form').submit(function(){
        $('#itemIdsList').val(itemIdsList.join(','));
        var l=itemIdsList.length;
        for (var i=0;i<l;i++) {
            var id = itemIdsList[i];
            var t = $('#type_'+id).val();
            if (t == 'title') {
                if ($('#time_'+id).val() == '') {
                    alert('发生时间不能为空');
                    return false;
                }
                if ($('#title_'+id).val() == '') {
                    alert('标题不能为空');
                    return false;
                }
            } else if (t == 'text') {
                if ($('#title_'+id).val() == '' && $('#text_'+id).val() == '') {
                    alert('文字'+id+'标题和内容至少填一项');
                    return false;
                }
            } else if (t == 'pic') {
                if ($('#picid_'+id).val() == '') {
                    alert('图片'+id+'不存在');
                    return false;
                }
            }
        }
    });
});
{/literal}
</script>

</body>
</html>
